#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    ll l,r;
    bool operator < (node o) const {
        if(l==o.l)return r<o.r;
        return l<o.l;
    }
}s[100005];
ll n,m,t,l,V,d[100005],a[100005],v[100005],p[100005],vis[100005];
int main () {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>V;
        for(int i=1;i<=100000;i++){
            s[i]={0,0};
            v[i]=d[i]=a[i]=p[i]=vis[i]=0;
        }
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];
        ll ans=0;
        ll cnt=0;
        for(int i=1;i<=n;i++){
            if(a[i]>=0){
                for(int j=1;j<=m;j++){
                    if(p[j]<d[i])continue;
                    else if(v[i]*v[i]+2*a[i]*(p[j]-d[i])>V*V){
                        ans++;
                        s[++cnt]={j,m};
                        break;
                    }
                }
            }
            else {
                ll A=0;
                ll B=0;
                for(int j=1;j<=m;j++){
                    if(p[j]<d[i])continue;
                    else if(v[i]*v[i]+2*a[i]*(p[j]-d[i])<=V*V){
                        B=j-1;
                        break;
                    }
                    else if(v[i]*v[i]+2*a[i]*(p[j]-d[i])>V*V&&A==0)A=j;
                }
                if(A==0)continue;
                else {
                    if(B==0)B=m;
                    ans++;
                    s[++cnt]={A,B};
                }
            }
        }
        cout<<ans<<" ";
        sort(s+1,s+cnt+1);
        ll mn=m+1;
        for(int i=cnt;i>=1;i--){
            if(mn>s[i].r){
                vis[s[i].l]=1;
                mn=s[i].l;
            }
        }
        ll sum=0;
        for(int i=1;i<=m;i++)sum+=1-vis[i];
        cout<<sum<<endl;
    }
    return 0;
}